/**
 * post sell
 */
// 图片上传
var set = {
	debug : false,
	flash_url : Y._ROOT_ + "/Public/js/swfupload/swfupload.swf",
	upload_url : Y._APP_ + '/News/uploadImage',  // 上传处理程序
	file_size_limit : "200 KB",
	file_types : "*.jpg;*.gif;*.png",
	file_upload_limit : 1,  // 允许上传1张
	file_queue_limit : 1,  // 队列最多1张
	custom_settings : {
		progressTarget : "fsUploadProgress"  // 文件队列容器id
		// 自己添加的方法 每个图片上传完成时调用
		,afterSuccessCallback : function(data){
			//alert(data);
			if(data.indexOf('error') > 0) {
				jQuery('#uploadMsg').html(data);
			} else {
				var viewimage = document.getElementById('viewimage');
				viewimage.value = data;  // 改成输出单张图片了
				//var overviewArea = document.getElementById('overview');
				//var arr = data.split('|');  // 原图 | 缩略图
				//var t = arr[0].substr(arr[0].lastIndexOf('/')+1);  // 把文件名截出来
				
				//viewimage.value = arr[1];  // 保存缩略图地址
				//overviewArea.innerHTML = '<img src="' + Y._ROOT_ + '/' + arr[1] + '" title="压缩预览图片"/>';
			}
		}
	},
	button_image_url : Y._CDN_ + "/images/upload-btns.png",
	button_placeholder_id : "spanButtonPlaceHolder"
};
var swfu = getSwfUpload(set);
// 开始上传函数
function myStartQueue() {
	//alert(1);
	swfu.startUpload(); 
}

// ckeditor
var smallEditor = CKEDITOR.replace( 'content', {
	toolbarGroups : [
		{ name: 'insert' },
		{ name: 'forms' },
		'/',
		{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
		{ name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align' ] },
		'/',
		{ name: 'styles' },
		{ name: 'colors' },
		{ name: 'document',    groups: [ 'mode', 'document' ] }
	],
	extraPlugins : 'insertpre',
	
	filebrowserBrowseUrl : Y._ROOT_ +'/Public/js/ckfinder/ckfinder.html',
	filebrowserImageBrowseUrl : Y._ROOT_ +'/Public/js/ckfinder/ckfinder.html?Type=Images',
	filebrowserFlashBrowseUrl : Y._ROOT_ +'/Public/js/ckfinder/ckfinder.html?Type=Flash',
	filebrowserUploadUrl : Y._ROOT_ +'/Public/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
	filebrowserImageUploadUrl : Y._ROOT_ +'/Public/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
	filebrowserFlashUploadUrl : Y._ROOT_ +'/Public/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
	
	,height:400
	,width:660
});

function postSell() {
	var err = '';
	var title = document.getElementById('title').value;
	var content = smallEditor.getData();
	
	if(title == '') {
		err += '请输入标题 \n';
	}
	if(content == '') {
		err += '请输入内容，内容小于1000字 \n';
	}
	
	if(err != '') {
		alert(err);
	} else {
		window.f1.submit();
	}
}

